var oPage_input = document.getElementsByClassName("page_input");//关键字输入框的父级
var oSxrMsg = document.getElementById("sxrMsg");//内容区域
var oPage_bar = document.getElementsByClassName("page_bar")[0];//分页导航栏

var page = {current:1,size:4,pages:0,total:0,serach:"",records:[]};
var search_str = "";
function firstPage() {
    page.current = 1;
    page.serach = oPage_input[0].children[0].value;
	search_str = page.serach;
    submit(page);
}
function prePage() {
    page.current -= 1;
    page.serach = oPage_input[0].children[0].value;
	search_str = page.serach;
    submit(page);
}
function nextPage() {
    page.current = page.current - 0 + 1;
    if (page.current > page.pages){
        page.current = page.pages
    }
    page.serach = oPage_input[0].children[0].value;
	search_str = page.serach;
    submit(page);
}
function lastPage() {
    page.current  = page.pages;
    page.serach = oPage_input[0].children[0].value;
	search_str = page.serach;
    submit(page);
}
function serach(){
	page.current = 1;
	page.serach = oPage_input[0].children[0].value;
	search_str = page.serach;
	submit(page);
}
function submit(mypage) {
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/PS/dishonesty/page" ,//url
            data: JSON.stringify(mypage),
			contentType: "application/json;charset=UTF-8",
            processData: false,
            cache: true,
            success: function (result) {
                page = result;
                var str = "";
                //内容区域
                for (var o in page.records) {
                    str += `<div class="sxr_msg" style="display: block;">
									<img src='${result.records[o].imgUrl}' alt="">
									<div class="sxr_border">
										<span class="sxr_desc">姓名:${result.records[o].name}</span>
										<span class="sxr_desc">案件号:${result.records[o].caseNumber}</span>
										<span class="sxr_desc">身份证号码:${result.records[o].identificationNumber}</span>
										<span class="sxr_desc">年龄:${result.records[o].age}</span>
										<span class="sxr_desc">地址:${result.records[o].address}</span>
										<span class="sxr_desc">未履行金额:${result.records[o].outstandingAmount}</span>
									</div>
									<span class="sxr_desc sxr_no"></span>
								</div>`;
                }
                oSxrMsg.innerHTML = str;
                //分页导航栏
                oPage_bar.innerHTML = `<div class="page_info">
								<span class="tot">共<span class="count">${result.total}</span>条记录
								</span> <span> 共<span class="pageCount">${result.pages}</span>页当前第
									<span class="nowpage">${result.current}</span>页 <a
									onclick="firstPage()">首页</a> <a   onclick="prePage()">上一页</a>
									<a   onclick="nextPage()">下一页</a> <a
									onclick="lastPage()">尾页</a>
								</span>
							</div>
							<div class="page_input">
								<input id="chaxun" type="text" placeholder="请输入关键字"
									value="${search_str}"><label for="chaxun" id="tijiao"
									onclick="serach()">查询</label>
							</div>`;
            }
        });
}
firstPage();